import time

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://121.43.169.97:8848/pageA.html")
# 定位confirma，点击
driver.find_element_by_css_selector("#confirma").click()
time.sleep(3)
# 获取警示框
alert = driver.switch_to.alert
# 打印警示框文本
print(alert.text)

# alert.dismiss() --> 取消对话框选项
alert.dismiss()
time.sleep(2)
# 定位到账号，输入admin
driver.find_element_by_css_selector("#userA").send_keys("admin")
# 关闭
time.sleep(2)
driver.quit()

